<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">

<head th:replace="admin/_fragments :: head(~{::title})">
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <!--    引入semantic.min.css-->
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.css"/>
  <!--    引入me.css-->
  <link rel="stylesheet" href="../../static/css/me.css"/>
  <!--    引入editormd.min.css-->
  <link rel="stylesheet" href="../../static/lib/editormd/css/editormd.min.css"/>
  <title>指南发布</title>
</head>
<body>

<!--导航-->
<nav th:replace="admin/_fragments :: menu(1)" class="ui inverted attached segment m-padded-tb-mini">
  <div class="ui container"> <!-- 加一个容器 -->
    <div class="ui inverted secondary stackable menu"> <!-- 菜单 stackable:可堆叠的,表示屏幕小时自动堆叠-->
      <h2 class="ui white header item">GuideSystem</h2> <!-- 蓝绿色标题 -->
      <a href="#" class="active m-item m-mobile-hide item"><i class="home icon"></i>博客</a> <!-- icon表示图表 -->
      <a href="#" class="m-item m-mobile-hide item"><i class="idea icon"></i>分类</a>
      <a href="#" class="m-item m-mobile-hide item"><i class="tags icon"></i>标签</a>
      <div class="right m-item m-mobile-hide menu">
        <div class="ui dropdown item">
          <div class="text">
            <img class="ui avatar image" src="https://unsplash.it/100/100?image=1005">
            软件214
          </div>
          <i class="dropdown icon"></i>
          <div class="menu">
            <a href="#" class="item">注销</a>
          </div>
        </div>
      </div>
    </div>
  </div>
  <a href="#" class="ui menu toggle black button icon m-top-right m-mobile-show">
    <i class="sidebar icon"></i>
  </a>
</nav>

<!--选择栏-->
<div cLass="ui attached pointing menu" style="margin-top: 4.4em;">
  <div class="ui container">
    <div class="right menu">
      <a href="#" th:href="@{/admin/resources/input}" class="blue active item">发布</a>
      <a href="#" th:href="@{/admin/resources}" class="item">列表</a>
    </div>
  </div>
</div>

<!--中间内容-->
<div class="m-container-large m-padded-tb-big animate__fadeIn" style="padding-top: 4em !important;">
  <div class="ui container">
    <form id="resource-form" action="#" th:object="${resource}" method="post" th:action="@{/admin/resources/post}"
          class="ui form">
      <input type="hidden" name="published"> <!--待优化-->
      <input type="hidden" name="id" th:value="*{id}">
      <div class="required field">
        <div class="ui left labeled input">
          <label class="ui basic label">标题</label>
          <input type="text" name="title" placeholder="标题..." th:value="*{title}">
        </div>
      </div>

      <div class="required field">
        <div id="md-content" style="z-index: 1 !important">
          <textarea placeholder="博客内容..." name="content" style="display: none" th:text="*{content}"></textarea>
        </div>
      </div>

      <div class="two fields">
        <div class="required field">
          <div class="ui left labeled action input">
            <label class="ui compact basic label">分类</label>
            <div class="ui fluid selection dropdown">
              <input type="hidden" name="type.id" th:value="*{type} != null ? *{type.id}">
              <i class="dropdown icon"></i>
              <div class="default text"></div>
              <div class="menu">
                <div th:each="type : ${types}" class="item" data-value="1" th:data-value="${type?.id}"
                     th:text="${type?.name}">错误日志
                </div>
                <!--/*-->
                <div class="item" data-value="2">开发者手册</div>
                <!--*/-->
              </div>
            </div>
          </div>
        </div>

        <div class="field">
          <div class="ui left labeled input">
            <label class="ui basic label">学校</label>
            <input type="text" name="school" th:value="*{school}" placeholder="学校对象...">
          </div>
        </div>
      </div>

      <div class="field">
        <div class="ui left labeled input">
          <label class="ui basic label">首图</label>
          <input type="text" name="firstPicture" th:value="*{firstPicture}" placeholder="首图引用地址...">
        </div>
      </div>

      <div class="required field">
        <textarea name="description" th:text="*{description}" placeholder="博客简介..." maxlength="200"></textarea>
      </div>

      <div class="ui error message"></div>

      <div class="ui right aligned container">
        <button type="button" class="ui button" onclick="window.history.go(-1)">返回</button>
        <button type="button" id="public-btn" class="ui blue button">发布</button>
      </div>
    </form>
  </div>
</div>

<!--底部footer-->
<footer th:replace="admin/_fragments :: footer" class="ui inverted vertical segment m-padded-tb-massive">
  <!-- vertical:垂直的 segment:条横 inverted:倒置的 -->
  <div class="ui center aligned container"> <!-- center aligned:居中 aligned:使成为一条线-->
    <div class="ui inverted divided stackable grid"> <!-- inverted divided grid:格线分成16份 -->
      <div class="three wide column">
        <div class="ui inverted link list">
          <div class="item">
            <img src="../../static/images/WeChat.jpg" class="ui rounded image" alt=""
                 style="width: 110px">
            <!-- rounded:圆角 -->
          </div>
        </div>
      </div>

      <!-- 分成三列 -->
      <div class="three wide column">
        <h4 class="ui inverted header m-text-thin">最新博客</h4>
        <div class="ui inverted link list">
          <a href="#" class="item m-text-thin">用户故事(User Story)</a>
          <a href="#" class="item m-text-thin">关于小熊是我对象这件事</a>
          <a href="#" class="item m-text-thin">摇滚乐牛逼!</a>
        </div>
      </div>

      <!-- 分成三列 -->
      <div class="three wide column">
        <h4 class="ui inverted header m-text-thin">联系我</h4>
        <div class="ui inverted link list">
          <a href="#" class="item m-text-thin" style="height: 28px">QQ: 1923326384</a>
          <a href="#" class="item m-text-thin">邮箱: 1923326384@qq.com</a>
        </div>
      </div>

      <!-- 分成七列 -->
      <div class="seven wide column">
        <h4 class="ui inverted header m-text-thin">个人留言</h4>
        <p class="m-text-thin m-text-spaced m-opacity-mini m-text-lined">
          第一次跟着视频敲项目，尽管很多不知道的知识点但还是慢慢吞吞地敲下来了，后续肯定会自己独立完成一些项目，希望可以鼓励到自己。</p>
      </div>

    </div>
    <div class="ui inverted section divider"></div>
    <p class="m-text-thin m-text-spaced m-opacity-tiny">Copyright @ 2021-2022 Hanyufan Designed by
      Hanyufan</p>
  </div>
</footer>

<th:block th:replace="admin/_fragments :: script">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.js"></script>
  <script src="../../static/lib/editormd/editormd.min.js"></script>
</th:block>

<!--点击执行操作  jss:JavaScript Semantic-ui-->
<script>
    $(function () {
        testEditor = editormd("md-content", {
            width: "100%",
            height: 640,
            syncScrolling: "single",
            path: "/dev/lib/editormd/lib/"
        });
    });

    $('.menu.toggle').click(function () {
        m - mobile - hide
        $('.m-item').toggleClass('');
    });

    $('.ui.dropdown').dropdown({
        on: 'hover'
    });

    $('#public-btn').click(function () {
        $('#resource-form').submit();
    })

    $('.ui.form').form({
        fields: {
            title: {
                identifier: 'title',
                rules: [{
                    type: 'empty',
                    prompt: '标题: 请输入博客标题'
                }]
            },

            content: {
                identifier: 'content',
                rules: [{
                    type: 'empty',
                    prompt: '内容: 请输入博客内容'
                }]
            },

            type: {
                identifier: 'type.id',
                rules: [{
                    type: 'empty',
                    prompt: '类别: 请输入博客类别'
                }]
            },

            description: {
                identifier: 'description',
                rules: [{
                    type: 'empty',
                    prompt: '简介: 请输入博客简介'
                }]
            }
        }
    });

    $('.message .close').on('click', function () {
        $(this).closest('.message').transition('fade');
    });
</script>
</body>
</html>